package com.cq.smartelebicycle.model;

import java.io.Serializable;

import android.database.Cursor;
import android.provider.MediaStore;

import com.cq.smartelebicycle.service.MediaPlaybackService;

public class Music implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public static final String[] MUSIC_COLS = new String[] {
			MediaStore.Audio.Media._ID, MediaStore.Audio.Media.ARTIST,
			MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.TITLE,
			MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.MIME_TYPE,
			MediaStore.Audio.Media.ALBUM_ID, MediaStore.Audio.Media.ARTIST_ID };
	
	private long id;// music id
	private String artist;// artist name
	private String album;// 专辑名
	private String title;// music name
	private String data;// music file path
	private String mimeType;// music mime type
	private long albumId;// album id
	private long artistId;// artisit id
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getArtist() {
		return artist;
	}
	public void setArtist(String artist) {
		this.artist = artist;
	}
	public String getAlbum() {
		return album;
	}
	public void setAlbum(String album) {
		this.album = album;
	}
	public long getAlbumId() {
		return albumId;
	}
	public void setAlbumId(long albumId) {
		this.albumId = albumId;
	}
	public long getArtistId() {
		return artistId;
	}
	public void setArtistId(long artistId) {
		this.artistId = artistId;
	}
	
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getData() {
		return data;
	}
	public void setData(String data) {
		this.data = data;
	}
	public String getMimeType() {
		return mimeType;
	}
	public void setMimeType(String mimeType) {
		this.mimeType = mimeType;
	}
	
	public Music initMusicFromCursor(Cursor cursor) {
		id = cursor.getLong(cursor.getColumnIndex(MUSIC_COLS[0]));
		artist = cursor.getString(cursor.getColumnIndex(MUSIC_COLS[1]));
		album = cursor.getString(cursor.getColumnIndex(MUSIC_COLS[2]));
		title = cursor.getString(cursor.getColumnIndex(MUSIC_COLS[3]));
		data = cursor.getString(cursor.getColumnIndex(MUSIC_COLS[4]));
		mimeType= cursor.getString(cursor.getColumnIndex(MUSIC_COLS[5]));
		albumId = cursor.getLong(cursor.getColumnIndex(MUSIC_COLS[6]));
		artistId = cursor.getLong(cursor.getColumnIndex(MUSIC_COLS[7]));
		return this;
	}

}
